#include <Qsci/qscilexerbash.h>
#include <Qsci/qscilexerbatch.h>
#include <Qsci/qscilexercpp.h>
#include <Qsci/qscilexercsharp.h>
#include <Qsci/qscilexercss.h>
#include <Qsci/qscilexerd.h>
#include <Qsci/qscilexerdiff.h>
#include <Qsci/qscilexerhtml.h>
#include <Qsci/qscilexeridl.h>
#include <Qsci/qscilexerjava.h>
#include <Qsci/qscilexerjavascript.h>
#include <Qsci/qscilexerlua.h>
#include <Qsci/qscilexermakefile.h>
#include <Qsci/qscilexerperl.h>
#include <Qsci/qscilexerpython.h>
#include <Qsci/qscilexerruby.h>
#include <Qsci/qscilexersql.h>

#include "LexerCenter.h"

class CppLexer : public QsciLexerCPP
{
	public:
		CppLexer() {
			// Comments
			setColor(QColor(150,150,150),QsciLexerCPP::CommentLine);
			setPaper(QColor(245,245,245),QsciLexerCPP::CommentLine);
			setFont(QFont("DejaVu Sans Mono",10,0,true),QsciLexerCPP::CommentLine);
			setColor(QColor(150,150,150),QsciLexerCPP::Comment);
			setPaper(QColor(245,245,245),QsciLexerCPP::Comment);
			setFont(QFont("DejaVu Sans Mono",10,0,true),QsciLexerCPP::Comment);
			setColor(QColor(150,150,150),QsciLexerCPP::CommentDoc);
			setPaper(QColor(245,245,245),QsciLexerCPP::CommentDoc);
			setFont(QFont("DejaVu Sans Mono",10,0,true),QsciLexerCPP::CommentDoc);
			setColor(QColor(150,150,150),QsciLexerCPP::CommentDocKeyword);
			setPaper(QColor(245,245,245),QsciLexerCPP::CommentDocKeyword);
			setFont(QFont("DejaVu Sans Mono",10,0,true),QsciLexerCPP::CommentDocKeyword);
			
			setColor(QColor(0,0,255),QsciLexerCPP::Number);
			
			setColor(defaultColor(QsciLexerCPP::PreProcessor),QsciLexerCPP::Keyword);
			setFont(QFont("DejaVu Sans Mono",10,0),QsciLexerCPP::Keyword);
			
			setColor(QColor(120,120,255),QsciLexerCPP::DoubleQuotedString);
			setColor(QColor(255,0,255),QsciLexerCPP::SingleQuotedString);
			setPaper(QColor(230,200,200),QsciLexerCPP::UnclosedString);
			
			setColor(QColor(40,40,140),QsciLexerCPP::Operator);
			setFont(QFont("DejaVu Sans Mono",10,0),QsciLexerCPP::Operator);
		}
};

LexerCenter::LexerCenter() {
	bash = 0;
	batch = 0;
	cmake = 0;
	cpp = 0;
	csharp = 0;
	css = 0;
	d = 0;
	diff = 0;
	html = 0;
	idl = 0;
	java = 0;
	javascript = 0;
	lua = 0;
	makefile = 0;
	perl = 0;
	pov = 0;
	properties = 0;
	python = 0;
	ruby = 0;
	sql = 0;
	tex = 0;
	vhdl = 0;
}

QsciLexer *LexerCenter::lexerForExtenssion(const QString &extension) {
	QsciLexer *lexer = 0;
	if (extension.compare("cpp") == 0 	||
		extension.compare("c") == 0 	||
		extension.compare("cxx") == 0 	||
		extension.compare("h") == 0 	||
		extension.compare("c++") == 0) 
	{
		if (!cpp) cpp = new CppLexer;
		lexer = cpp;
	}
	
	if (extension.compare("run") == 0	||
		extension.compare("sh") == 0	||
		extension.compare("bash") == 0)
	{
		if (!bash) bash = new QsciLexerBash;
		lexer = bash;
	}
	
	if (extension.compare("css") == 0)
	{
		if (!css) css = new QsciLexerCSS;
		lexer = css;
	}
	
	if (extension.compare("cs") == 0)
	{
		if (!csharp) csharp = new QsciLexerCSharp;
		lexer = csharp;
	}
	
	if (extension.compare("patch") == 0)
	{
		if (!diff) diff = new QsciLexerDiff;
		lexer = diff;
	}
	
	if (extension.compare("d") == 0)
	{
		if (!d) d = new QsciLexerD;
		lexer = d;
	}
	
	if (extension.compare("html") == 0	||
		extension.compare("htm") == 0	||
		extension.compare("php") == 0	||
		extension.compare("xml") == 0)
	{
		if (!html) html = new QsciLexerHTML;
		lexer = html;
	}
	
	if (extension.compare("java") == 0)
	{
		if (!java) java = new QsciLexerJava;
		lexer = java;
	}
	
	if (extension.compare("js") == 0)
	{
		if (!javascript) javascript = new QsciLexerJavaScript;
		lexer = javascript;
	}
	
	if (extension.compare("pl") == 0	||
		extension.compare("cgi") == 0	||
		extension.compare("pm") == 0)
	{
		if (!perl) perl = new QsciLexerPerl;
		lexer = perl;
	}
	
	if (extension.compare("py") == 0)
	{
		if (!python) python = new QsciLexerPython;
		lexer = python;
	}
	
	if (extension.compare("sql") == 0)
	{
		if (!sql) sql = new QsciLexerSQL;
		lexer = sql;
	}
	
	return lexer;
}
